﻿using XLugia.Lib.XDataBase.Base.Lib;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace XDataBase.Demo.Common.Data
{
    public class PublicVariables
    {
        private static PublicVariables _instance = new PublicVariables();
        public static PublicVariables getIns() { return _instance; }

        /// <summary>
        /// 服务器数据库连接串
        /// </summary>
        public string serverConnectString {
            get
            {
                return string.Format(XDBConfig.serverConnectString
                                            , XDBConfig.serverName
                                            , XDBConfig.databaseName
                                            , XDBConfig.sqlUser
                                            , XDBConfig.sqlPassword);
            }
        }

        /// <summary>
        /// 服务器连接超时设定
        /// </summary>
        public static int serverConnectTimeout
        {
            get
            {
                return XDBConfig.serverConnectTimeout;
            }
        }

        /// <summary>
        /// 服务器类型
        /// </summary>
        public const DatabaseConnector.DatabaseTypes serverConnectType = DatabaseConnector.DatabaseTypes.MSSQL;
    }

    public class XDBConfig
    {
        /// <summary>
        /// 服务器数据库连接串
        /// </summary>
        public static string serverConnectString
        {
            get
            {
                return "data source={0};initial catalog={1};persist security info=True;user id={2};password={3};connect timeout=30;MultipleActiveResultSets=True;App=EntityFramework";
            }
        }

        /// <summary>
        /// 服务器连接超时设定
        /// </summary>
        public static int serverConnectTimeout = 30;

        /// <summary>
        /// 服务器名
        /// </summary>
        public static string serverName
        {
            get
            {
                return ".";
            }
        }

        /// <summary>
        /// 数据库名
        /// </summary>
        public static string databaseName
        {
            get
            {
                return "XDataBaseDemo";
            }
        }

        /// <summary>
        /// 基础设置中的数据库用户名
        /// </summary>
        public static string sqlUser
        {
            get
            {
                return "sa";
            }
        }

        /// <summary>
        /// 基础设置中的数据库用户密码
        /// </summary>
        public static string sqlPassword
        {
            get
            {
                return "ABC123abc";
            }
        }
    }
}
